//
//  LCGlobalBookViewController.m
//  lechuang
//
//  Created by Mr_hi on 2024/8/27.
//  Copyright © 2024 Mooyi. All rights reserved.
//

#import "LCGlobalBookViewController.h"
#import "LCGolbalVideoCollectionViewCell.h"

@interface LCGlobalBookViewController ()<UICollectionViewDelegateFlowLayout, UICollectionViewDataSource>

@property (weak, nonatomic) IBOutlet UICollectionView *collectionView;

@property (assign, nonatomic)NSInteger page;
@property (strong, nonatomic)NSMutableArray * dataArr;

@end

@implementation LCGlobalBookViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.page = 1;
    [self setContentViewRefresh];
}

-(void)setContentViewRefresh {
    self.collectionView.mj_header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{
        self.page = 1;
        [self getBookData:1];
    }];
    self.collectionView.mj_header.automaticallyChangeAlpha = YES;
    
    self.collectionView.mj_footer = [MJRefreshAutoNormalFooter footerWithRefreshingBlock:^{
        self.page++;
        [self getBookData:self.page];
    }];
    self.collectionView.ly_emptyView = [LCEmptyView emptyViewWithImage:nil titleStr:@"暂无数据～" detailStr:nil];
}

- (void)getBookData:(NSInteger)page {
    
}

-(NSMutableArray *)dataArr {
    if (!_dataArr) {
        _dataArr = [NSMutableArray array];
    }
    return _dataArr;
}

- (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout insetForSectionAtIndex:(NSInteger)section {
    return UIEdgeInsetsMake(0, 17, 14, 17);
}

-(CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout minimumInteritemSpacingForSectionAtIndex:(NSInteger)section {
    return 14;
}

-(CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout minimumLineSpacingForSectionAtIndex:(NSInteger)section {
    return 14;
}

-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
//    return self.dataArr.count;
    return 12;
}

-(CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath {
    CGFloat cellW = ceilf((ScreenW-34-28)/3.0);
    CGFloat cellH = ceil(cellW * 60/53.0) + 45;
    return CGSizeMake(cellW, cellH);
}

-(__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
    LCGolbalVideoCollectionViewCell * cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"LCGolbalBookCollectionViewCell" forIndexPath:indexPath];
    return cell;
}

-(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
    
}

@end
